﻿namespace ExamV5.Persion
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmHelpInfo : Page
    {
        protected Button butClose;
        protected Button butDefault;
        protected DropDownList DDLUser;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private int int_0 = 0;
        protected Label labList;
        protected Label labSendUserCode;
        protected Label labSendUserName;
        protected Panel PanelAdd;
        protected Panel PanelShow;
        private PublicFun publicFun_0 = new PublicFun();
        protected TextBox txtDoc;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            if (this.DDLUser.SelectedItem.Value != "0")
            {
                if (this.txtDoc.Text.Trim() == "")
                {
                    base.Response.Write("<script>alert('求助内容不可以为空！');</script>");
                }
                else
                {
                    string strSql = "Insert into SysTip(InfoTitle,InfoContent,InfoURL,FormType,Flag,GetNumber,SendNumber,Formtable,FormID) values(";
                    strSql = string.Concat(new object[] { strSql, "'','", this.publicFun_0.CheckString(this.txtDoc.Text), "','','A','A','", this.publicFun_0.CheckString(this.DDLUser.SelectedItem.Value), "','", this.httpCookie_0.Value, "','','", this.int_0, "')" });
                    strSql = string.Concat(new object[] { strSql, ";update SysTip set Flag='B' where GetNumber='", this.httpCookie_0.Value, "' and FormID=", this.int_0, ";Insert into SysTip(InfoTitle,InfoContent,InfoURL,FormType,Flag,GetNumber,SendNumber,Formtable,FormID) values(" });
                    strSql = string.Concat(new object[] { strSql, "'有一条求助信息等待您的处理！','','Persion/HelpInfoList.aspx','B','A','", this.publicFun_0.CheckString(this.DDLUser.SelectedItem.Value), "','", this.httpCookie_0.Value, "','SysTip',", this.int_0, ")" });
                    this.publicFun_0.ExecuteSql(strSql);
                    base.Response.Write("<script>alert('编辑求助信息操作成功！');parent.location.reload();window.close();</script>");
                }
            }
            else
            {
                base.Response.Write("<script>alert('请选择接收人员信息！');</script>");
            }
        }

        private void method_0()
        {
            this.labList.Text = string.Empty;
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand(string.Concat(new object[] { "select * from SysTip where (GetNumber='", this.httpCookie_0.Value, "' or SendNumber='", this.httpCookie_0.Value, "') and FormType='A' and (ID=", this.int_0, " or FormID=", this.int_0, ") order by FormID,ID" }), connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                //this.labList.Text = this.labList.Text + "<table id='table3' borderColor='#cccccc' cellSpacing='0' borderColorDark='#cccccc' cellPadding='0' width='100%'  border='1' style='border-style:Solid;'>";
                //this.labList.Text = this.labList.Text + "<tr bgColor='#ffffff' height='30'><td align='center'  width='80'><b>内容信息</b></td><td align='left' >" + reader["InfoContent"].ToString() + "</td></tr>";
                //this.labList.Text = this.labList.Text + "<tr bgColor='#f5fcfe' height='30'><td align='center'  width='80'><b>发起人员</b></td><td align='left' >" + this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + reader["SendNumber"].ToString() + "'", "UserName") + "</td></tr>";
                //this.labList.Text = this.labList.Text + "<tr bgColor='#ffffff' height='30'><td align='center'  width='80'><b>接收人员</b></td><td align='left' >" + this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + reader["GetNumber"].ToString() + "'", "UserName") + "</td></tr>";
                //this.labList.Text = this.labList.Text + "</table><br>";

                this.labList.Text += "<div>";

                this.labList.Text += "<div class=\"layui-form-item\">";
                this.labList.Text += "<label class=\"layui-form-label p0\">内容信息</label>";
                this.labList.Text += "<div class=\"layui-input-block\">" + reader["InfoContent"].ToString() + "</div>";
                this.labList.Text += "</div>";

                this.labList.Text += "<div class=\"layui-form-item\">";
                this.labList.Text += "<label class=\"layui-form-label p0\">发起人员</label>";
                this.labList.Text += "<div class=\"layui-input-block\">" + this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + reader["SendNumber"].ToString() + "'", "UserName") + "</div>";
                this.labList.Text += "</div>";

                this.labList.Text += "<div class=\"layui-form-item\">";
                this.labList.Text += "<label class=\"layui-form-label p0\">接收人员</label>";
                this.labList.Text += "<div class=\"layui-input-block\">" + this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + reader["GetNumber"].ToString() + "'", "UserName") + "</div>";
                this.labList.Text += "</div>";

                this.labList.Text += "</div>";
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            this.int_0 = Convert.ToInt32(base.Request["ID"].ToString());
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                base.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "---求助信息中心";
                if (!base.IsPostBack)
                {
                    this.butDefault.Attributes.Add("onclick", "javascript:{if(confirm('确定要发送求助相关信息！')==false) return false;}");
                    this.publicFun_0.ExecuteSql("delete SysTip where GetNumber='" + this.httpCookie_0.Value + "' and Formtable='SysTip'");
                    if (this.int_0 != 0)
                    {
                        this.PanelShow.Visible = true;
                        this.method_0();
                        this.DDLUser.Enabled = false;
                        this.DDLUser.Items.Clear();
                        string values = this.publicFun_0.GetValues("select GetNumber from SysTip where FormType='A' and ID=" + this.int_0, "GetNumber");
                        if (!(values != this.httpCookie_0.Value))
                        {
                            this.labSendUserCode.Text = this.publicFun_0.GetValues("select SendNumber from SysTip where FormType='A' and ID=" + this.int_0, "SendNumber");
                            this.labSendUserName.Text = this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + this.publicFun_0.CheckString(this.labSendUserCode.Text) + "'", "UserName");
                        }
                        else
                        {
                            this.labSendUserCode.Text = values;
                            this.labSendUserName.Text = this.publicFun_0.GetValues("select UserName from UserInfo where UserCode='" + this.publicFun_0.CheckString(this.labSendUserCode.Text) + "'", "UserName");
                        }
                        this.DDLUser.Items.Insert(0, new ListItem(this.labSendUserName.Text, this.labSendUserCode.Text));
                        string str2 = this.publicFun_0.GetValues("select top 1 SendNumber from SysTip where FormID=" + this.int_0 + " order by ID", "SendNumber");
                        string strSql = string.Concat(new object[] { "delete SysTip where FormType='B' and GetNumber='", this.httpCookie_0.Value, "' and Formtable='SysTip' and FormID=", this.int_0 });
                        if (str2 != this.httpCookie_0.Value)
                        {
                            strSql = string.Concat(new object[] { strSql, ";update SysTip set Flag='B' where GetNumber='", this.httpCookie_0.Value, "' and ID=", this.int_0 });
                        }
                        this.publicFun_0.ExecuteSql(strSql);
                    }
                    else
                    {
                        this.PanelShow.Visible = false;
                        this.DDLUser.Enabled = true;
                        this.DDLUser.Items.Clear();
                        this.DDLUser.DataTextField = "UserName";
                        this.DDLUser.DataValueField = "UserCode";
                        this.DDLUser.DataSource = this.publicFun_0.RetrunDataView("select UserName,UserCode from UserInfo where (UserLevel='C' or UserLevel='B' )");
                        this.DDLUser.DataBind();
                        this.DDLUser.Items.Insert(0, new ListItem("--请选择人员--", "0"));
                    }
                }
            }
        }
    }
}

